﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Manager/Base.Master" AutoEventWireup="true" CodeBehind="UserList.aspx.cs" Inherits="YXQ.Manager.Manager.UserList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
        $(function () {
            $('#dg').datagrid({
                title: '员工列表',
                iconCls: 'icon icon-nav',
                height: 400,
                nowrap: true,
                autoRowHeight: false,
                striped: true,
                url: "../Handler/DataHandler.ashx?OpType=GetUser",
                sortOrder: 'desc',
                remoteSort: false,
                pagination: true,
                columns: [[
                        { field: 'Id', title: 'ID', width: 80 },
                        { field: 'UserName', title: '用户名', width: 150 },
                        { field: 'RealName', title: '姓名', width: 150 },
                        { field: 'Email', title: '邮箱', width: 200 },
                        { field: 'Tel', title: '联系电话', width: 200 },
                           { field: 'Status', title: '是否禁用', width: 60,formatter:IsUsedFormat },
                        {
                            field: 'opt', title: '操作', width: 200, align: 'center',
                            formatter: function (value, rec) {

                                return "<a href='javascript:' onclick='Edit(" + rec.Id + ")'>编辑</a>&nbsp;&nbsp;<a href='javascript:' onclick='SetRight("+rec.Id+")'>设置权限</a>&nbsp;&nbsp;<a href='javascript:' onclick='Del(" + rec.Id + ")'>删除</a>";
                            }
                        }
                ]],
                toolbar: [{
                    id: 'btnadd',
                    text: '添加',
                    iconCls: 'icon-add',
                    handler: function () {
                        YXQ.Manager.OpenDialog("UserDetail.aspx", "添加员工", 500);
                    }
                }]


            });

        });

        function IsUsedFormat(val) {
            var rtn="";
            if (val == "0") {
                rtn = "否";
            } else {
                rtn = "<font color='red'>是</font>";
            }
            return rtn;
        }

        function SetRight(val) {
            YXQ.Manager.OpenDialog("UserRight.aspx?id=" + val, "设置用户权限", 600,500);
        }


        function Edit(val) {
            YXQ.Manager.OpenDialog("UserDetail.aspx?id=" + val, "修改用户", 600,300);
        }
        function Del(val) {
            YXQCore.Form.PostData("../Handler/CommonHandler.ashx",
                                { OpType: "DelUser", PostData: val },
                                function (data) {

                                    if (data.ResultMessage == "Success") {
                                        YXQ.Common.Message("恭喜你操作已经成功");
                                        $("#dg").datagrid("reload");
                                        return;
                                    }

                                });
        }
        function SearchUser() {
            $('#dg').datagrid('load', {
                Whr: $('#txtUserName').val(),
                RealName:$("#txtRealName").val()
            });
        }

    </script>


    <table cellspacing="0" cellpadding="0" width="100%" class="admintable">
        <tr>
            <td>
                <table cellspacing="0" cellpadding="0" class="admintable01">
                    <tr>
                        <td style="width: 20px;">
                            <img src="../images/carfromtable_01.gif" style="margin-top: 2px;" />
                        </td>
                        <td>
                            <b>位置：</b>员工管理
                        </td>
                        <td style="width: 50px;"></td>
                        <td style="width: 50px;"></td>
                        <td style="width: 15px;"></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td height="10"></td>
        </tr>
    </table>

    <table class="tbs_table">
        <tr>
            <td class="tdtitle">用户名：</td>
             <td class="tdtitle"><input type="text"  id="txtUserName" /></td>
            <td class="tdtitle">姓名：</td>
             <td class="tdtitle"><input type="text"  id="txtRealName" /></td>
             <td class="tdtitle"><input type="button"  class="bt_wb1"  value="搜索"  onclick="SearchUser();"/></td>
        </tr>
    </table>
    <table id="dg">
    </table>
    

</asp:Content>
